/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.cip.esymons.colegiatura.be;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
import org.cip.esymons.general.be.ConsejoDepartamental;

/**
 *
 * @author ADMINISTRADOR
 */
@Entity
@Table(name = "col_detalle_sancion")
//@NamedQueries({@NamedQuery(name = "DetalleSancion.findAll", query = "SELECT d FROM DetalleSancion d"),
//@NamedQuery(name = "DetalleSancion.findByDsaCodigo", query = "SELECT d FROM DetalleSancion d WHERE d.dsaCodigo = :dsaCodigo"),
//@NamedQuery(name = "DetalleSancion.findByDsaDocumento", query = "SELECT d FROM DetalleSancion d WHERE d.dsaDocumento = :dsaDocumento"),
//@NamedQuery(name = "DetalleSancion.findByDsafechaRegistro", query = "SELECT d FROM DetalleSancion d WHERE d.dsafechaRegistro = :dsafechaRegistro")})
public class DetalleSancion implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "dsa_codigo")
    private Long dsaCodigo;
    @Basic(optional = false)
    @Column(name = "dsa_documento")
    private String dsaDocumento;
    @Basic(optional = false)
    @Column(name = "dsa_fechaRegistro")
    @Temporal(TemporalType.DATE)
    private Date dsafechaRegistro;
    @Basic(optional = false)
    @Column(name = "dsa_rutaDocumento")
    private String dsarutaDocumento;

    @JoinColumn(name = "col_codigo", referencedColumnName = "col_codigo")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Colegiado colegiado;
    @JoinColumn(name = "san_codigo", referencedColumnName = "san_codigo")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Sancion sanCodigo;

    @Transient
    private ConsejoDepartamental consejo;

    public DetalleSancion() {
    }

    public DetalleSancion(Long dsaCodigo) {
        this.dsaCodigo = dsaCodigo;
    }

    public DetalleSancion(Long dsaCodigo, Date dsafechaRegistro) {
        this.dsaCodigo = dsaCodigo;
        this.dsafechaRegistro = dsafechaRegistro;
    }

    public Long getDsaCodigo() {
        return dsaCodigo;
    }

    public void setDsaCodigo(Long dsaCodigo) {
        this.dsaCodigo = dsaCodigo;
    }

    public Date getDsafechaRegistro() {
        return dsafechaRegistro;
    }

    public void setDsafechaRegistro(Date dsafechaRegistro) {
        this.dsafechaRegistro = dsafechaRegistro;
    }

    public String getFechaRegistroSancion(){
        SimpleDateFormat sd =  new SimpleDateFormat("dd/MM/yyyy");
        return sd.format(dsafechaRegistro);
    }

    public Colegiado getColegiado() {
        return colegiado;
    }

    public void setColegiado(Colegiado colegiado) {
        this.colegiado = colegiado;
    }   

    public Sancion getSanCodigo() {
        return sanCodigo;
    }

    public void setSanCodigo(Sancion sanCodigo) {
        this.sanCodigo = sanCodigo;
    }

    public String getDsaDocumento() {
        return dsaDocumento;
    }

    public void setDsaDocumento(String dsaDocumento) {
        this.dsaDocumento = dsaDocumento;
    }

    public String getDsarutaDocumento() {
        return dsarutaDocumento;
    }

    public void setDsarutaDocumento(String dsarutaDocumento) {
        this.dsarutaDocumento = dsarutaDocumento;
    }

    public ConsejoDepartamental getConsejo() {
        return consejo;
    }

    public void setConsejo(ConsejoDepartamental consejo) {
        this.consejo = consejo;
    }
    
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (dsaCodigo != null ? dsaCodigo.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof DetalleSancion)) {
            return false;
        }
        DetalleSancion other = (DetalleSancion) object;
        if ((this.dsaCodigo == null && other.dsaCodigo != null) || (this.dsaCodigo != null && !this.dsaCodigo.equals(other.dsaCodigo))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.cip.esymons.colegiatura.be.DetalleSancion[dsaCodigo=" + dsaCodigo + "]";
    }


    @Transient
    private String aplication;

    public String getAplication() {
        return aplication;
    }

    public void setAplication(String aplication) {
        this.aplication = aplication;
    }
    
}
